import pymysql
import redis


db_config = {
        'host':'122.114.195.118',
        'port':3306,
        'user': 'admin',
        'password': 'Root110qwe',
        'db': 'crm',
        'charset': 'utf8',
    }
conn = pymysql.connect(**db_config)
cur = conn.cursor()
def connect_mysql_sql(cur,conn,sql_2,moshi='select'): #连接MySQL
    cur.execute(sql_2)
    conn.commit()
    if moshi == 'select':
        tuple_rcs = cur.fetchall()
        return tuple_rcs
    cur.close()
    conn.close()

def connect_redis_sql(db): #连接redis
    mdb = redis.StrictRedis(host='122.114.195.118', port=6379, db=db, decode_responses=True,password='ma1114')#
    return mdb

mdb = connect_redis_sql(1)
note = mdb.get('name')
print(note)

sql3 = "select * from tb_work where id in (1,2,3,4,5,6)"
for i in connect_mysql_sql(cur,conn,sql3):
    print(i)